/*! \file
 * \brief The interface file for the MythFile library.
 *
 * The MythFile library defines a few functions to manipulate the filesystem. You
 * can open files for reading and for writing, set the working directory.
 *
 * \author Ivo Wingelaar
 * \date 2011
 * \version 0.1.0
 * \copyright GNU Lesser General Public License v3
 */

#ifndef __MYTH_FILE_HPP_INCLUDED__
#define __MYTH_FILE_HPP_INCLUDED__

#include "MythStream.hpp"

#if (!defined _MYTH_FILE_EXTENSION_)
    #if ((!defined _MYTH_FILE_STATIC_LIBRARY_) && \
         (!defined _MYTH_FILE_DYNAMIC_LIBRARY_))
        #error Please define which version of the library you are using.
    #endif

    #ifdef _MYTH_WINDOWS_
        #ifdef _MYTH_FILE_STATIC_LIBRARY_
            #define _MYTH_FILE_API_
        #endif // _MYTH_FILE_STATIC_LIBRARY_

        #ifdef _MYTH_FILE_LIBRARY_
            #ifdef _MYTH_FILE_EXPORT_
                #define _MYTH_FILE_API_ __declspec(dllexport)
            #else
                #define _MYTH_FILE_API_ __declspec(dllimport)
            #endif // _MYTH_FILE_EXPORT_
        #endif // _MYTH_FILE_DYNAMIC_LIBRARY_
    #endif // _MYTH_WINDOWS_

    #ifdef _MYTH_LINUX_
        #define _MYTH_FILE_API_
    #endif // _MYTH_LINUX_
#endif // _MYTH_FILE_EXTENSION_

namespace Myth
{
//! The namespace of the MythFile library.
namespace File
{

#if (!defined _MYTH_FILE_EXTENSION_)

    //! Creates an input from a file.
    /*!
     * \return A pointer to an input from a file.
     * \param[in] stream_name Name of the stream.
     * \param[in] file_name Path to the file you want to open for reading.
     */
    extern "C" _MYTH_FILE_API_ Stream::Input* _MYTH_CALL_CONV_ create_input_file(const std::string& stream_name, const std::string& file_name);

    //! Creates an output to a file.
    /*!
     * \return A pointer to an output to a file.
     * \param[in] stream_name Name of the stream.
     * \param[in] file_name Path to the file you want to open for writing.
     * \param[in] append If true and the file already exists, any data written will be appended to it, otherwise it will create a new file.
     */
    extern "C" _MYTH_FILE_API_ Stream::Output* _MYTH_CALL_CONV_ create_output_file(const std::string& stream_name, const std::string& file_name, bool append = false);

    ////////////////////////////////////////////////////////////////////////////
    //! Returns the version of the MythFile library.
    /*!
     * \return The version of the MythFile library.
     */
    extern "C" _MYTH_FILE_API_ uint32_t _MYTH_CALL_CONV_ get_myth_file_version(void);

#endif // _MYTH_FILE_EXTENSION_

} // namespace File
} // namespace Myth

#endif // __MYTH_FILE_HPP_INCLUDED__

